﻿/* 
 *  <copyright file="CGuid.cs" company="Wesley Jowitt">
 *  
 *  SobrietyEngine: Copyright (c) 2011 Wesley Jowitt
 *  
 *  This software is distributed under a software license.
 *   * As of the creation time of this file, the license in use is the Microsoft Permissive License (Ms-PL) 
 *    * The license can be viewed at:
 *     * License.Txt in the root folder of this project
 *      * http://sobrietyengine.codeplex.com/license
 *       * http://www.microsoft.com/opensource/licenses.mspx
 *       
 *  </copyright>
 *   */

using System;
using System.Collections.Generic;

namespace SobrietyEngine.UDMF
{
    public class Linedef : BaseUDMFObject
    {
        public int[] VertPairIndex { get; set; }
        public int SidedefFrontIndex { get; set; }
        public int SidedefBackIndex { get; set; }
        public Boolean Blocking { get; set; }
        public Boolean TwoSided { get; set; }
        public Dictionary<String, String> Data { get; private set; }

        public Linedef()
        {
            VertPairIndex = new int[2];
            Blocking = false;
            TwoSided = false;
        }

        override public void Read(Dictionary<String,String> kvps)
        {
            SidedefFrontIndex = Int32.Parse(kvps["sidefront"]);
            SidedefBackIndex = Int32.Parse(kvps["sideback"]);

            VertPairIndex[0] = Int32.Parse(kvps["v1"]);
            VertPairIndex[1] = Int32.Parse(kvps["v2"]);

            if (kvps.ContainsKey("blocking"))
                Blocking = Boolean.Parse(kvps["blocking"]);

            if (kvps.ContainsKey("twosided"))
                TwoSided = Boolean.Parse(kvps["twosided"]);

            Data = kvps;
        }
    }
}
